"use strict"
var db = require('../db-connection');

class restaurantDB {
    getAllRestaurant(request, respond){
        var sql = "SELECT * FROM areyouhungry.restaurant;";
        db.query(sql, function(error, result){
            if(error){
                throw error;
            }
            else{
                respond.json(result);
            }
        });
    }
    findOne(req, res){
        var sql = `SELECT * FROM areyouhungry.restaurant where Restaurant_id=${req.body.goodsId};`;
        db.query(sql, function(error, result){
            if(error){
                throw error;
            }
            else{
                res.json(result);
            }
        });
    }
    searchType(req,res){
        var sql = `SELECT * FROM areyouhungry.restaurant where food='${req.body.food}';`;
        db.query(sql, function(error, result){
            if(error){
                throw error;
            }
            else{
                res.json(result);
            }
        });
    }
}

module.exports = restaurantDB;